﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TelnetRouterApplication
{
    public class IpModel
    {
        private string _ip;
        public string ip
        {
            get { return _ip; }
            set { _ip = value; }
        }
        private int _port;
        public int port
        {
            get { return _port; }
            set { _port = value; }
        }

        public IpModel(string ip, int port)
            : this(ip)
        {
            this.port = port;
        }

        public IpModel(string ip)
        {
            this.ip = ip;
        }

        public override string ToString()
        {
            StringBuilder toReturn = new StringBuilder();
            if (ip != null)
            {
                toReturn.Append(ip);
            }
            if (port != null && port > 0)
            {
                toReturn.Append(port);
            }
            return toReturn.ToString();
        }

        public bool Equals(object obj)
        {
            if (obj is IpModel)
            {
                IpModel ipModel2 = (IpModel)obj;
                return ip.Equals(ipModel2.ip) && port.Equals(ipModel2.port);
            }

            return false;
        }
    }
}
